/**
 * 
 */
package com.taobao.wolfwolf.hibernate.service.impl;

import java.util.List;

import com.taobao.wolfwolf.hibernate.dao.SpecificationDao;
import com.taobao.wolfwolf.hibernate.pojo.Specification;
import com.taobao.wolfwolf.hibernate.service.SpecificationService;

/**
 * @author qinanhg@gmail.com
 *
 * 创建时间: 2012-1-3 下午3:22:39
 */
public class SpecificationServiceImpl extends BaseServiceImpl implements
		SpecificationService {
	private SpecificationDao sdao;
	/* (non-Javadoc)
	 * @see com.taobao.wolfwolf.hibernate.service.SpecificationService#findById(int)
	 */
	@Override
	public Specification findById(int id) {
		try {
			return sdao.findById(id);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("按序号查找规格出错");
		}
		return null;
	}

	/* (non-Javadoc)
	 * @see com.taobao.wolfwolf.hibernate.service.SpecificationService#findByName(java.lang.String)
	 */
	@Override
	public List<Specification> findByName(String name) {
		try {
			sdao.findByName(name);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("按名称查找规格出错");
		}
		return null;
	}

	/* (non-Javadoc)
	 * @see com.taobao.wolfwolf.hibernate.service.SpecificationService#findAll()
	 */
	@Override
	public List<Specification> findAll() {
		try {
			sdao.findAll();
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("按查找全部规格出错");
		}
		return null;
	}

	/* (non-Javadoc)
	 * @see com.taobao.wolfwolf.hibernate.service.SpecificationService#paging(int, int)
	 */
	@Override
	public List<Specification> paging(int page, int limit) {
		try {
			sdao.paging(page, limit);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("查找规格分布出错");
		}
		return null;
	}

	/* (non-Javadoc)
	 * @see com.taobao.wolfwolf.hibernate.service.SpecificationService#getTotal()
	 */
	@Override
	public long getTotal() {
		try {
			return sdao.getTotal();
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("查找规格总数出错");
		}
		return -1;
	}

	/* (non-Javadoc)
	 * @see com.taobao.wolfwolf.hibernate.service.SpecificationService#hasEntity(com.taobao.wolfwolf.hibernate.pojo.Specification)
	 */
	@Override
	public int hasEntity(Specification specs) {
		try {
			return sdao.hasEntity(specs);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("按对象查找出错");
		}
		return -1;
	}

	public SpecificationDao getSdao() {
		return sdao;
	}

	public void setSdao(SpecificationDao sdao) {
		this.sdao = sdao;
	}

	@Override
	public int removeAll() {
		try {
			sdao.removeAll();
		} catch (Exception e) {
			e.printStackTrace();
			return -1;
		}
		return 1;
	}

	@Override
	public Integer getMaxId() {
		try {
			return sdao.getMaxId();
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("获取规格最大值出错");
		}
		return null;
	}
}
